//导入axios实例
import { instance } from '@/request'
const ENV = import.meta.env

// 封装http请求
//来自黄浦大屏的接口
class Http {
  static BASE_URL = ENV.VITE_APP_API_URL
  static getHttp(url, params) {
    return new Promise((resolve, reject) => {
      instance
        .get(this.BASE_URL + url, {
          params: params || {}
        })
        .then((res) => {
          resolve(res)
        })
    })
  }
  static postHttp(url, msg) {
    return new Promise((resolve, reject) => {
      instance.post(this.BASE_URL + url, msg).then((res) => {
        resolve(res)
      })
    })
  }
  // 办公区，公共场所，文教区，医疗机构，餐饮机构，其他
  static getPoint() {
    return this.getHttp(`/shljdwgl/queryList`)
  }
  //居民区
  static getpointResidential() {
    return this.getHttp(`/shljJzqGl/queryList`)
  }
  //集贸市场
  static getpointMarket() {
    return this.getHttp(`/shljyjspgl/queryList`)
  }
  //中转站
  static gettransferStation() {
    return this.getHttp(`/flzysjgl/queryList`)
  }
  //垃圾量统计
  static garbageStatistics(msg) {
    return this.getHttp(`/tOilReport/queryMap?type=${msg}`)
  }
  //完成进度
  static completionProgress() {
    return this.getHttp(`/tRecord/queryList`)
  }
  //源头与末端对比
  static sourceEnd() {
    return this.getHttp(`/tRubbishCirculation/queryListByDate`)
  }
  //垃圾流向
  static wasteflowDirection() {
    return this.getHttp(`/tRubbishCirculation/queryList`)
  }
  //检查点分布
  static checkpointDistribution() {
    return this.getHttp(`/dataaccess/jcdfb`)
  }
  static dataAccessList(params) {
    const { streetName } = params
    if (streetName) {
      params['streetName'] = streetName + '街道'
    }
    return this.getHttp(`/dataaccess/queryList`, params)
  }
  //检查点分布得分排名 固定排序
  static scoreList(params) {
    // return this.getHttp(`/ssh/dataaccess/queryList`)
    // 跳过 token 认证
    return this.getHttp(`/dataaccess/dataList`, params)
  }
  // 区/各街道 平均分
  static avgScore(params) {
    return this.getHttp(`/dataaccess/avgGradle`, params)
  }
  // 检查地点数量、达标率查询
  static pointCountAndRateGroup(params) {
    return this.getHttp(`/dataaccess/countGroup`, params)
  }
  //检查点位得分分布
  static scoreDistribution() {
    return this.getHttp(`/dataaccess/jcdwdffb`)
  }
  //检查点得分分布平均分
  static scoreDistributionaverage() {
    return this.getHttp(`/dataaccess/jcdwdffbpjf`)
  }
  //获取车辆列表-新
  static carList() {
    return this.getHttp(`/syqyclgl/carList`)
  }
  //获取车辆轨迹
  static carDetail(msg) {
    return this.getHttp(
      `/syqyclgl/carDetail?car=${msg.car}&startTime=${msg.startTime}&endTime=${msg.endTime}`
    )
  }
  //获取车辆实时轨迹
  static carTracked(msg) {
    return this.getHttp(`/syqyclgl/carRealTime?car=${msg.carNumber}`)
  }
  //垃圾投放点 垃圾收集点 小型垃圾转运站压缩站清洁站 公共厕所 作业养护道班房
  static rubbishPoint(msg) {
    return this.getHttp(`/tFeatureInfo/queryList?typename=${msg}`)
  }
  //湿垃圾品质概况
  static wetGarbageline() {
    return this.postHttp(`/rubbishData/queryListByAvg`)
  }
  static wetGarbagepie(msg) {
    return this.postHttp(`/rubbishData/queryListByMouth?mouth=${msg.time}&type=${msg.type}`)
  }
  // 黄浦区干湿比
  static wetdryRadio(param) {
    return this.getHttp(
      `/wetLitter/getLargeScreenData?year=${param.year}&yearMonth=${param.yearMonth}&type=${param.type}`
    )
  }
  // 撒点图片
  static getPointImage(param) {
    return this.getHttp(`/shljJzqGl/getFile?imgPath=${param.imgPath}`)
  }
  // 天气
  static getWeather() {
    return new Promise((resolve, reject) => {
      instance
        .get(
          'https://restapi.amap.com/v3/weather/weatherInfo?city=310101&key=a9d58c87bd6e60543ba3c5fc4c894ccc'
        )
        .then((res) => {
          resolve(res)
        })
        .catch((error) => {
          reject(error)
        })
    })
  }
  // 检查点类型及数量
  static getTypeAndPoint() {
    return this.getHttp(`/checkpointQuantity/queryList`)
  }
  // 垃圾量统计-收运单位
  static getTransportationUnit(param) {
    return this.getHttp(
      `/classifyRubbish/getUnitRecycelByYear?year=${param.year}&month=${param.month}`
    )
  }
  // 垃圾量统计-街道
  static getStreetWaste(param) {
    return this.getHttp(`/classifyRubbish/getStreetByYear?year=${param.year}&month=${param.month}`)
  }
  // 检查点位得分排名
  static getRankCondition(param) {
    return this.getHttp(`/pointLocationScore/queryList?date=${param}`)
  }
}
export { Http }
